package com.dshore.messagecenter.controller.basedata;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * 获取session
 * @author panyi
 *
 */
public class BaseController {
	
	public HttpSession getSession() {
		HttpServletRequest request=((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
		return request.getSession();
	}
	
	//从session中获取系统当前登录用户的ID
	public String getIdFromSession(HttpSession session) {
		Object idObject = session.getAttribute("user");
		if(idObject==null) {
			return null;
		}else {
			return idObject.toString();
		}
	}
	
}
